home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: MiscTimedEntry.h
- * Version: 1.0
- * Author: James T. Romano
- * Summary: This class defines a timer that will call back a
- * target object with a selectable message. The timer may be
- * set up to go off once, repeat a N times, or repeat indefinately.
- * Also, the timer may be run in another thread.
- *
- * Revision History:
- * Dec 1994 james created
- * Dec 1994 steveq tweaked
- *
- * Copyright 1994 James T. Romano james@hbsd-im.telerate.com
- *
- * A timed entry blocks, waiting for a timer return, then sends the
- * action message to the target. A timed entry may be run in it's own
- * thread, providing an asyncronous interupt, or run, providing a
- * thread safe blocking timer. Of course, when run in it's own thread,
- * the call back will be run in the timer's thread.
- *
- * Time is measured in milliseconds.
- * Action methods *must* be of the form " - methodName:sender;"
- * When sent, 'sender' will be the MiscTimedEntry instance.
- *
- * An example:
- * MiscTimedEntry *te = [[MiscTimedEntry alloc] init];
- * [te setTarget:someTarget];
- * [te setAction:@selector(someActionForTarget:)];
- * [te setInterval:5*1000]; // 5 second interval
- * [te setUserData:someData];
- * if (async)
- * [te runInNewThread]; // returns immediately
- * else
- * [te run]; // sender blocked until 'run' ends
- *
- *
- */
- #import <misckit/MiscThreadedObject.h>
- #import <mach/port.h>
-
- @interface MiscTimedEntry : MiscThreadedObject
- {
- void *userdata;
- id target; // instance that will receive a call
- SEL action; // A method that a target responds to
- int interval; // Time to wait in milliseconds
- port_t port; // Mach port for this object.
- int repeatCount; // a value of -1 => forever (default)
- }
-
- - init;
- - initWithTarget:aTarget action:(SEL)anAction interval:(int)ival data:(void *)data;
-
- // This method runs the entry
- // If it returns nil, then you haven't properly set the target
- // and action for this object.
- - run;
- - stop; /* stops the timer without freeing it */
- - free; /* stops (if needed) and frees */
-
- #ifdef DONTDEFINE
- // this would be compatabile with NS 3.3
- - (void)setTarget:sender;
- - (void)setAction:(SEL)anAction;
- #endif
-
- #ifndef DONTDEFINE
- // we define it this way for now to be compatible with NS 3.2
- - setTarget:sender;
- - setAction:(SEL)anAction;
- #endif
-
- - (void)setInterval:(int)anInterval;
- - (void)setUserData:(void *)userData;
- - (void)setRepeatCount:(int)count;
-
- // Set mach port so communication to a timed entry is possible
- - (void)setPort:(int)aPort;
-
- - (void *)userData;
- - target;
- - (SEL)action;
- - (int)interval;
- - (int)port;
- - (int)repeatCount;
-
- @end
-
-